<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * For example, it puts together the home page when no home.php file exists.
 *
 */
global $woo_options, $loop, $wp_query;

get_header(); ?>
    
<?php woo_main_before();?>

<?php
$term = get_term_by("slug",get_query_var("tinh-trang"),"tinh-trang");
$cterm = $term;
if($term->parent!=0){
    $term = get_term_by("id",$term->parent,"tinh-trang");
}



$childs = get_terms("tinh-trang",array('hide_empty'=>false,"parent"=>$term->term_id,"orderby"=>"custom_sort","order"=>"asc"));
?>


<?php
//print_r(get_query_var("tinh-trang"));exit;
// print_r(get_query_var("tinh-trang")."zxc asd ndp");
$wp_query = new WP_Query(array(
    'post_type' => 'san-pham',
    'orderby' => 'date',
    'order' => 'desc',
    'posts_per_page' => $woo_options['woo_products_per_page'],
    'paged' => ( get_query_var( 'page' ) ? absint( get_query_var( 'page' ) ) : 1 ),
    'status' => array('publish','private'),
    'tax_query' => array(
        array(
            'taxonomy' => 'tinh-trang',
            'field' => 'slug',
            'terms' => get_query_var("tinh-trang")
        )
    )
));
print_r($wp_query);
?>
<?php //print_r(get_query_var("tinh-trang")."zxc asd ndp");exit;

echo get_query_var("tinh-trang"); ?>
<div class="row-fluid">
	<div class="span3 sidebar-left-col">
		<?php get_sidebar("left");?>
	</div>
	 
	<div id="wrap-list-product" class="span9">

		<div id="category-product" class="wrap-products">
           <div class="banner-product"><?php get_template_part("content","bannerdm") ?></div>
			<div class="products">
				<?php $loop=1; while($wp_query->have_posts()) { $wp_query->the_post();?>
					<?php get_template_part("content","product");?>
                    <?php if($loop%4==0){?>
                    <div class="clearfix"></div>
                    <?php } ?>  
				<?php  $loop++; } ?>
			</div>
			<div class="clearfix"></div>
			<hr />
			<div class="ar navigation">
				<?php woo_pagination(array('type' => 'list'));?>
			</div>
		</div>
		<?php wp_reset_query();?>
	</div>
	
</div>
<hr />
<script>
/*
jQuery(function($){
    $("#price-range li a,#select-color li a").click(function(){
        $(".loading").show();
        $(this).parents("ul").find(".active").removeClass("active");
		
        $(this).parent("li").addClass("active");
        var idmucgia = $("#price-range").find(".active").children("a").attr("rel");
        var idcolor = $("#select-color").find(".active").children("a").attr("rel");
        var datas = {
            'danh-muc':<?php echo $cterm->term_id?>,
            'muc-gia': idmucgia,
            'mau' : idcolor
        };
        var link = "<?php echo admin_url("admin-ajax.php?action=get-list-product");?>";
        $.get(link, datas, function(rdata){
            $(".loading").hide();
            $(".to-top a").click();
			$("#wrap-list-product").html(rdata);
        });
        return false;
    })
});
*/
</script>

<?php woo_main_after();?> 

<?php get_footer(); ?>